package com.google.code.customercare.exception;

import org.apache.log4j.Logger;

import com.google.code.customercare.common.BaseAction;

public class LogUnhandleExceptionAction extends BaseAction{
	
	private Exception exception;
	
	private static Logger log = Logger.getLogger("unhandle-exception");
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String execute() {
		 	if(exception != null){
			 	log.error("UNHANDLE EXCEPTION: ", exception);
			 	 addActionError(getText("common.unknown.exception"));
	        } else {
	            log.error("***** TRIED TO LOG EXCEPTION BUT EXCEPTION WAS NULL! I HAVE NOT LOGGED THIS EXCEPTION! *****");
	            addActionError(getText("could.not.log.exception"));
	        }
	        return "ERROR";
	}

	public Exception getException() {
		return exception;
	}

	public void setException(Exception exception) {
		this.exception = exception;
	}

	@Override
	protected boolean checkToken() {
		return false;
	}

	@Override
	protected void rememberToken() {
	}

}
